package web.test.exception;


import com.netflix.zuul.exception.ZuulException;

/**
 * @非中断性系统异常 - 合理业务异常
 * RC checked 异常基类，可以存储RspCodeMsg
 */
public class BizException extends ZuulException {

	private static final long serialVersionUID = 87012420802149926L;

	/**
	 * 子类需要设置一个默认的异常返回状态码
	 */
	protected ErrorCode codeMsg;

	private String message;

	/**
	 * 运行时的入参
	 */
	protected Object object;


	public BizException(ErrorCode codeMsg) {
		super(codeMsg.getErrMsg(), 200, codeMsg.getErrMsg());
		this.codeMsg = codeMsg;
	}

	/**
	 * 非中断性系统异常 - 合理业务异常
	 * @param codeMsg
	 * @param object 业务异常对应的请求参数
	 */
	public BizException(ErrorCode codeMsg, Object object) {
		this(codeMsg);
		this.codeMsg = codeMsg;
		this.object = object;
	}

	public BizException(ErrorCode codeMsg, String message) {
		this(codeMsg);
		this.codeMsg = codeMsg;
	}

	public BizException(ErrorCode codeMsg, String message, Throwable cause) {
		this(codeMsg, message);
		this.codeMsg = codeMsg;
	}

	public BizException(ErrorCode codeMsg, Throwable cause) {
		super(cause, codeMsg.getErrMsg(), 200, codeMsg.getErrMsg());
		this.codeMsg = codeMsg;
	}

	public ErrorCode getCodeMsg() {
		return codeMsg;
	}

	public void setCodeMsg(ErrorCode codeMsg) {
		this.codeMsg = codeMsg;
	}

	public String getMessage() {
		return message;
	}
}
